package com.fuxian.dao.mybatisImpl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.stereotype.Repository;

import com.fuxian.dao.StudentDao;
import com.fuxian.model.Student;
@Repository
public class StudentDaoMybatisImpl implements StudentDao {
	@Resource
	private SqlSessionTemplate sqlSessionTemplate;
	public void addStudent(Student student) {
		sqlSessionTemplate.insert("addStudent",student);

	}

	public void deleteStudentById(int id) {
		sqlSessionTemplate.delete("deleteStudentById", id);

	}

	public void modifyStudent(Student student) {
		sqlSessionTemplate.update("modifyStudent", student);
	}

	public List<Student> selectAllStudent(int start,int size) {
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("start", start);
		map.put("size", size);
		List<Student>list=sqlSessionTemplate.selectList("selectAllStudent", map);
		return list;
	}
	public Student selectStudentById(int id) {
		Student student=sqlSessionTemplate.selectOne("selectStudentById", id);
		return student;
	}

	public int selectStudentCount() {
		return sqlSessionTemplate.selectOne("selectStudentCount");
	}


}
